﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using FSViet.Survey.Helpers;

namespace FSViet.Survey.Administration.Site
{
	public partial class List : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				int page = 1;
				try
				{
					page = Convert.ToInt32(Request.QueryString["p"]);
				}
				catch
				{
				}
				LoadData(page);
			}
		}

		void LoadData(int page)
		{
			page = page - 1;
			if (page < 0) page = 0;
			try
			{
				DataHelper dataH = new DataHelper();

				var data = dataH.Load("SELECT * FROM Sites", page * GlobalApplication.ItemPerPage, GlobalApplication.ItemPerPage);
				ListItem.DataSource = data;
				ListItem.DataBind();
			}
			catch (Exception ex)
			{
				msg.Text = ex.Message;
#if DEBUG
				msg.Text = ex.ToString();
#endif
			}
		}
	}
}